﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.Restaurant.Dto
@using FwProject.Core.Restaurant
@model IPagedList<LoadCarOutputDto>
@{
    Layout = null;
    decimal total = 0;
    int disRes = 0;
    int i = 0;
    if (Model.Count > 0)
    {
        if (Model.PageNumber != 1)
        {
            i = (Model.PageNumber - 1) * Model.PageSize;
        }
    }
}
<div id="table_print" style="max-height:600px;overflow-y:scroll;">
    <table class="table table-bordered table-hover table-rowselected">
        <thead>
            <tr>
                <th class="collapsed"></th>
                <th style="width:45px">序号</th>
                <th>审核状态</th>
                <th>装车单号</th>
                <th>装车日期</th>
                <th>车牌号</th>
                <th>司机</th>
                <th>总装箱数量</th>
                <th>配送状态</th>
                <th>已配送餐厅数</th>
                @*<th style="width:50px;">操作</th>*@
            </tr>
        </thead>
        <tbody>
            @if (Model.Count == 0)
            {
                <tr><td class="text-center" colspan="10"></td></tr>
            }
            else
            {
                foreach (var item in Model)
                {
                    i++;
                    <tr>
                        <td class="collapsed"><i class="fa fa-plus-square-o" data-id="@item.Id"></i></td>
                        <td>@i</td>
                        @if (item.ExamineStatus == ExamineStatus.未审核)
                        {
                            <td style="color:red">@item.ExamineStatus.ToString()</td>
                        }
                        else
                        {
                            <td style="color:green">@item.ExamineStatus.ToString()</td>
                        }
                        <td><a href="javascript:top.window.openTab(1056,'装车单[@item.CreationNumber]','@Url.Action("ExamineLoadingCar",new { id=item.Id})')">@item.CreationNumber</a></td>
                        <td>@item.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
                        <td>@(item.CarInfoModel != null ? item.CarInfoModel.PlatesNumber : "")</td>
                        <td>@(item.DriverName)</td>
                        <td>@(item.LoadingCarInfoList != null ? item.LoadingCarInfoList.Sum(o => o.Countproduct) : 0)</td>
                        <td>@(item.CarStatus.ToString())</td>
                        <td>@item.DeliveredCount</td>
                    </tr>
                    <tr data-selectable="false" class="tb-child hidden">
                        <td colspan="13">
                            <div class="row m-b-lg">
                                <div class="col-sm-12" style="width:100%">
                                    <div class="tabs-container">
                                        <div class="tabs-left">
                                            <div class="tab-content ">
                                                <div class="tab-pane active">
                                                    <div class="panel-body" style="width:100%; margin-left:0;">
                                                        @if (item.LoadingCarInfoList.Count > 0)
                                                        {
                                                            <table class="table table-bordered table-hover table-rowselected table-rowselected">
                                                                <thead>
                                                                    <tr>
                                                                        <th>货品</th>
                                                                        <th>包装数</th>
                                                                        <th>单位</th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody class="tb_tbody"></tbody>
                                                            </table>
                                                        }
                                                        else
                                                        {
                                                            <strong>（暂无配送单据）</strong>
                                                        }
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    if (item.LoadingCarInfoList != null)
                    {
                        total = total + item.LoadingCarInfoList.Sum(o => o.Countproduct);
                    }
                    disRes += item.DeliveredCount;
                }
                <tr class="footer" style="color:red">
                    <td class="text-center" colspan="2">合计</td>
                    <td colspan="5"></td>
                    <td>@total</td>
                    <td></td>
                    <td>@disRes</td>
                </tr>
            }
        </tbody>
    </table>

</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        @*共 @Model.TotalItemCount 条，@Model.PageSize 条/页 当前第 @Model.PageNumber/@Model.PageCount 页*@
        共 @Model.TotalItemCount 条，
        <select class="form-control" id="pageSize" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select> &nbsp;条/页 当前第 @Model.PageNumber/@Model.PageCount 页
    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&PlatesNumber=@(Context.Request.Query["PlatesNumber"])&BeginLimit=@(Context.Request.Query["BeginLimit"])&EndLimit=@(Context.Request.Query["EndLimit"])&DriverId=@(Context.Request.Query["DriverId"])&ExamineStatus=@(Context.Request.Query["ExamineStatus"])"/>
        @Html.PagedListPager(Model, page => Url.Action("LoadingInvoice", new { id = page,
       size = Context.Request.Query["size"],
       PlatesNumber = Context.Request.Query["PlatesNumber"],
       BeginLimit = Context.Request.Query["BeginLimit"],
       EndLimit = Context.Request.Query["EndLimit"],
       DriverId = Context.Request.Query["DriverId"],
       ExamineStatus = Context.Request.Query["ExamineStatus"]}), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list" ,OnSuccess= "AjaxSuccessCallback",OnBegin= "AjaxBegin" }))
    </div>
</div>
